package com.tentact.coolmeetingtest.controller.servlet; /**
 * @author 星环
 * @date 2023/1/10 19:54:08
 * @description
 */

import com.tentact.coolmeetingtest.annotation.RequestParam;
import com.tentact.coolmeetingtest.service.DeptService;
import com.tentact.coolmeetingtest.support.MyMessage;
import com.tentact.coolmeetingtest.support.RetMsg;

public class DeptServlet{
    DeptService deptService = new DeptService();

    public MyMessage regselect() {
        return MyMessage.of(false,"register.jsp","depts",deptService.getAllDept());
    }

    public MyMessage showall()  {
        return MyMessage.of(false,"departments.jsp","depts",deptService.getAllDept());
    }

    public MyMessage add(@RequestParam("dept_name") String dept_name) {
        RetMsg retMsg = deptService.addDept(dept_name);
        return MyMessage.of(true,"dept.showall","msg",retMsg.msg);
    }
    public MyMessage delete(@RequestParam("deptno")int deptno){
        RetMsg retMsg = deptService.deleteDept(deptno);
        return MyMessage.of(true,"dept.showall","msg",retMsg.msg);
    }
    public MyMessage update(@RequestParam("deptno") int deptno, @RequestParam("dept_name") String deptName){
        RetMsg retMsg = deptService.updateDept(deptno,deptName);
        return MyMessage.of(true,"dept.showall","msg",retMsg.msg);
    }
}
